#!../../bin/linux-x86_64/SDS6204

#- You may have to change SDS6204 to something else
#- everywhere it appears in this file

< envPaths

cd "${TOP}"

## Register all support components
dbLoadDatabase "dbd/SDS6204.dbd"
SDS6204_registerRecordDeviceDriver pdbbase

epicsEnvSet "STREAM_PROTOCOL_PATH" "$(TOP)/db"
epicsEnvSet "P" "HLSII:BD:"
#epicsEnvSet "R" "BSTL3:"
epicsEnvSet "R" "BCMSOFT:"
epicsEnvSet("POINTS","10000000")
#epicsEnvSet("ETHER","192.168.116.233:5025")

## Ensure that we can transfer a complete waveform
epicsEnvSet(EPICS_CA_MAX_ARRAY_BYTES, 500000000)
cd "${TOP}"

# Set up ASYN ports
#drvAsynIPPortConfigure("L0", "$(ETHER)", 0, 0, 0)

## Load record instances
#dbLoadRecords("db/xxx.db","user=ioc")

#dbLoadRecords("db/bcm.db","user=ioc")

dbLoadRecords("db/devSOFTIOC.db","P=$(P),R=$(R),PORT=L0,POINTS=$(POINTS)")
#dbLoadTemplate "db/devSOFTIOC.substitutions"
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=0,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=1,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=2,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=3,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=4,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=5,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=6,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=7,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=8,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=9,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=10,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=11,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=12,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=13,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=14,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=15,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=16,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=17,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=18,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=19,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=20,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=21,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=22,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=23,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=24,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=25,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=26,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=27,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=28,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=29,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=30,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=31,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=32,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=33,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=34,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=35,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=36,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=37,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=38,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=39,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=40,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=41,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=42,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=43,POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-Bunch.db","P=$(P),R=$(R),BunchNo=44,POINTS=$(POINTS)")

dbLoadRecords("db/devSOFTIOC-CH.db","P=$(P),R=$(R),PORT=L0,CH="A",POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-CH.db","P=$(P),R=$(R),PORT=L0,CH="B",POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-CH.db","P=$(P),R=$(R),PORT=L0,CH="C",POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-CH.db","P=$(P),R=$(R),PORT=L0,CH="D",POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-CH.db","P=$(P),R=$(R),PORT=L0,CH="SUM",POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-CH.db","P=$(P),R=$(R),PORT=L0,CH="X-Y",POINTS=$(POINTS)")
dbLoadRecords("db/devSOFTIOC-CH.db","P=$(P),R=$(R),PORT=L0,CH="X+Y",POINTS=$(POINTS)")

#dbLoadRecords("db/devSOFTIOC-CH-long.db","P=$(P),R=$(R),PORT=L0,CH=A,POINTS=$(POINTS)")
#dbLoadRecords("db/devSOFTIOC-CH-long.db","P=$(P),R=$(R),PORT=L0,CH=B,POINTS=$(POINTS)")
#dbLoadRecords("db/devSOFTIOC-CH-long.db","P=$(P),R=$(R),PORT=L0,CH=C,POINTS=$(POINTS)")
#dbLoadRecords("db/devSOFTIOC-CH-long.db","P=$(P),R=$(R),PORT=L0,CH=D,POINTS=$(POINTS)")

cd "${TOP}/iocBoot/${IOC}"

#set_requestfile_path("./")
#set_savefile_path("./autosave")
#set_pass0_restoreFile("ct_settings.sav")
#set_pass1_restoreFile("ct_settings.sav")
#save_restoreSet_DatedBackupFiles(1)

iocInit

#dbpf $(P)$(R)TIM:RANG_SP 5e-5
#dbpf $(P)$(R)SetWavWidt WORD
#dbpf $(P)$(R)TRIG:SOUR_SP 4
#dbpf $(P)$(R)TRIG:SWE_SP NORM
#dbpf $(P)$(R)TRIG:LEV_SP 0.4

dbl > pvlist.txt

## Start any sequence programs
#seq sncxxx,"user=ioc"
#var streamDebug 1
# save things every thirty seconds
#create_monitor_set("ct_settings.req", 30,"P=$(P),R=$(R)")
